Math and Complex Number Routines Category

=====================================================

 

Abs Routine Returns an absolute value.

Syntax

function Abs(const AValue: TComplex): Double;

Description

Abs returns the absolute value of the argument, X. X is an integer-type or real-type expression.

=====================================================

 

ArcCos Routine Calculates the inverse cosine of a given number.

Syntax

function ArcCos(const AValue: TComplex): TComplex;

Description

ArcCos returns the inverse cosine of X. X must be between -1 and 1. The return value is in the range [0..Pi], in radians.

=====================================================

 

ArcCosH Routine Calculates the inverse hyperbolic cosine of a given number.

Syntax

function ArcCosH(const AValue: TComplex): TComplex;

Description

ArcCosh returns the inverse hyperbolic cosine of X. The value of X must be greater than or equal to 1.
=====================================================

 

ArcCot Routine Calculates the inverse cotangent of a given number.

Syntax

function ArcCot(const AValue: TComplex): TComplex;

Description

ArcCot returns the inverse cotangent of X.

=====================================================

 

ArcCotH Routine Calculates the inverse hyperbolic cotangent of a given number.

Syntax

function ArcCotH(const AValue: TComplex): TComplex;

Description

ArcCot returns the inverse hyperbolic cotangent of X.

=====================================================

 

ArcCsc Routine Calculates the inverse cosecant of a given number.

Syntax

function ArcCsc(const AValue: TComplex): TComplex;

Description

ArcCsc returns the inverse cosecant of X.

=====================================================

 

ArcCscH Routine Calculates the inverse hyperbolic cosecant of a given number.

Syntax

function ArcCscH(const AValue: TComplex): TComplex;

Description

ArcCsc returns the inverse hyperbolic cosecant of X.
=====================================================

 

ArcSec Routine Calculates the inverse secant of a given number.

Syntax

function ArcSec(const AValue: TComplex): TComplex;

Description

ArcSec returns the inverse secant of X.

=====================================================

 

ArcSecH Routine Calculates the inverse hyperbolic secant of a given number.

Syntax

function ArcSecH(const AValue: TComplex): TComplex;

Description

ArcSec returns the inverse hyperbolic secant of X.
=====================================================

 

ArcSin Routine Calculates the inverse sine of a given number.

Syntax

function ArcSin(const AValue: TComplex): TComplex;

Description

ArcSin returns the inverse sine of X. X must be between -1 and 1. The return value will be in the range [-Pi/2..Pi/2], in radians.
=====================================================

 

ArcSinH Routine Calculates the inverse hyperbolic sine of a given number.

Syntax

function ArcSinH(const AValue: TComplex): TComplex;

Description

ArcSinh returns the inverse hyperbolic sine of X.

=====================================================

 

ArcTan Routine Calculates the arctangent of a given number.

Syntax

function ArcTan(const AValue: TComplex): TComplex;

Description

In Delphi code, ArcTan returns the arctangent of X. X is a real-type expression that gives an angle in radians.

=====================================================


ArcTan2 Routine Calculates the arctangent angle and quadrant of a given number.

Syntax

function ArcTan2(const Y: Extended, const X: Extended): Extended;

Description

ArcTan2 calculates ArcTan(Y/X), and returns an angle in the correct quadrant. The values of X and Y must be between -2^64 and 2^64.

In addition, the value of X can’t be 0. The return value will fall in the range from -Pi to Pi radians.
=====================================================


ArcTanH Routine Calculates the inverse hyperbolic tangent of a given number.

Syntax

function ArcTanH(const AValue: TComplex): TComplex;

Description

ArcTanh returns the inverse hyperbolic tangent of X. The value of X must be between -1 and 1 (inclusive).

=====================================================

 

Ceil Routine Rounds variables up toward positive infinity.

Syntax

function Ceil(const X: Extended): Integer;

Description

 Call Ceil to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt.

For example: Ceil(-2.8) = -2 Ceil(2.8) = 3 Ceil(-1.0) = -1

=====================================================

 

Cos Routine Calculates the cosine of an angle.

Syntax

function Cos(const AValue: TComplex): TComplex;

Description

In Delphi code, Cos returns the cosine of the angle X. X is a real-type expression that represents an angle in radians.
=====================================================


Cosecant Routine Returns the cosecant of an angle.

Syntax

function Cosecant(const AValue: TComplex): TComplex;

Description

Use the Cosecant to calculate the cosecant of X, where X is an angle in radians. The cosecant is calculated as 1/ Sin(X).
=====================================================


CosH Routine Calculates the hyperbolic cosine of an angle.

Syntax

function CosH(const AValue: TComplex): TComplex;

Description

Use the Cosh to calculate the hyperbolic cosine of X.
=====================================================


Cot Routine Calculates the cotangent of an angle.

Syntax

function Cot(const AValue: TComplex): TComplex;

Description

Call Cot to obtain the cotangent of X. The cotangent is calculated using the formula 1 / Tan(X).
=====================================================

 

Cotan Routine Calculates the cotangent of an angle.

Syntax

function Cotan(const AValue: TComplex): TComplex;

Description

Call Cotan to obtain the cotangent of X. The cotangent is calculated using the formula 1 / Tan(X)

Note: Note:Do not call Cotan with X = 0.

=====================================================

 

CotH Routine Calculates the hyperbolic cotangent of an angle.

Syntax

function CotH(const AValue: TComplex): TComplex;

Description

Call CotH to obtain the hyperbolic cotangent of X, where X is an angle in Radians.

=====================================================

 

Csc Routine Returns the cosecant of an angle.

Syntax

function Csc(const AValue: TComplex): TComplex;

Description

Use the Csc to calculate the cosecant of X, where X is an angle in radians.

=====================================================

 

CscH Routine Returns the hyperbolic cosecant of an angle.

Syntax

function CscH(const AValue: TComplex): TComplex;

Description

Use the CscH to calculate the hyperbolic cosecant of X, where X is an angle in radians.

=====================================================

 

DegToRad Routine Returns the value of a degree measurement expressed in radians.

Syntax

function DegToRad(const Degrees: Extended): Extended;

Description

Use DegToRad to convert angles expressed in degrees to the corresponding value in radians, where radians = degrees(pi/180).
=====================================================

 

DoubleDecliningBalance Routine Calculates the depreciation of an asset using the double-declining balance method.

Syntax

function DoubleDecliningBalance(const Cost: Extended, const Salvage: Extended, Life: Integer, Period: Integer): Extended;

Description

DoubleDecliningBalance determines accelerated depreciation values for an asset, given the initial Cost, Life expectancy, end value, and depreciation Period.

=====================================================

 

Floor Routine Rounds variables toward negative infinity.

Syntax

function Floor(const X: Extended): Integer;

Description

Call Floor to obtain the highest integer less than or equal to X. For example: Floor(-2.8) = -3 Floor(2.8) = 2 Floor(-1.0) = -1

Note: Note:The absolute value of X must be less than MaxInt.

=====================================================

 

FutureValue Routine Calculates the future value of an investment.

Syntax

function FutureValue(const Rate: Extended, NPeriods: Integer, const Payment: Extended, const PresentValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

 FutureValue returns the future value of an investment of PresentValue where Payment is invested for NPeriods at the rate of Rate per period. The PaymentTime parameter indicates whether the investment is an ordinary annuity or an annuity due (enter 0 if payments are at the end of each period, 1 if they are at the beginning).
=====================================================

 

Exp Routine Returns the exponential of X.

Syntax

function Exp(const AValue: TComplex): TComplex;

Description

In Delphi code, Exp returns the value of e raised to the power of X, where e is the base of the natural logarithms.
=====================================================

 

Frac Routine Returns the fractional part of a real number.

Syntax

function Frac(const AValue: Double): Double;

Description

In Delphi code, the Frac function returns the fractional part of the argument X. X is a real-type expression. The result is the fractional part of X; that is, Frac(X) = X - Int(X).
=====================================================

 

Int Routine Returns the integer part of a real number.

Syntax

function Int(const AValue: Double): Double;

Description

In Delphi code, Int returns the integer part of X; that is, X rounded toward zero. X is a real-type expression

=====================================================

 

InterestPayment Routine Calculates the interest portion of a loan payment.

Syntax

function InterestPayment(const Rate: Extended, Period: Integer, NPeriods: Integer, const PresentValue: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

 Call InterestPayment to calculate the portion of a loan payment that reflects the interest. Rate represents the fixed periodic interest rate. Period identifies the payment period. NPeriods is the number of periods of the loan. PresentValue represents the amount borrowed (the principal). FutureValue is the future value of the investment. PaymentTime indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning).
=====================================================

 

InterestRate Routine Returns the interest rate required to increase PresentValue to FutureValue.

Syntax

function InterestRate(NPeriods: Integer, const Payment: Extended, const PresentValue: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

InterestRate calculates the interest rate required in order for an investment of PresentValue, with periodic payments of Payment, to be worth FutureValue within NPeriods compounding periods. If NPeriods represents years, an annual interest rate results; if NPeriods represents months, a monthly interest rate results, and so on. The PaymentTime parameter indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning). 
=====================================================

 

InternalRateOfReturn Routine Calculates the internal rate of return for an investment.

Syntax

function InternalRateOfReturn(const Guess: Extended, const CashFlows: array of Double (1,2,3...)): Extended;

Description

InternalRateOfReturn determines the internal rate of return on an investment. It references an array that contains cash flow information and uses the supplied internal rate of return estimate to calculate results. Before using this function, define an array containing expected cash flow amounts over a period of time. It is assumed that the amounts are received at regular intervals. Negative amounts are interpreted as cash outflows, and positive amounts as inflows. The first amount must be a negative number, to reflect the initial investment. The following amounts can all be the same for each time period, or they can be different (including a mixture of negatives, positives, or zeros). Specify the estimated rate of return as the Guess parameter. Pass the array of expected cash flow amounts as the CashFlows parameter.
=====================================================

 

IsNan Routine Indicates when a variable or expression does not evaluate to a numeric value.

Syntax

function IsNan(const AValue: Double): Boolean;

Description

Use IsNan to test whether the value specified by AValue represents NaN (not a number). Note that NaN is distinct from positive and negative infinity, which can be detected using the IsInfinite function.
=====================================================

 

Ln, Log Routines Returns the natural log of a real expression.

Syntax

function Ln(const AValue: TComplex): TComplex;

Description

 In Delphi code, Ln returns the natural logarithm (Ln(e) = 1) of the real-type expression X.
=====================================================

 

LnXP1 Routine Returns the natural log of (X+1)

Syntax

function LnXP1(const X: Extended): Extended;

Description

LnXP1 returns the natural logarithm of (X+1). Use LnXP1 when X is a value near 0.
=====================================================

 

Log10 Routine Calculates log base 10.

Syntax

function Log10(const AValue: TComplex): TComplex;

Description

Log10 returns the log base 10 of X.
=====================================================

 

Log2 Routine Calculates log base 2.

Syntax

function Log2(const AValue: TComplex): TComplex;

Description

Log2 returns the log base 2 of X.

=====================================================

 

LogN Routine Calculates the log of X for a specified base.

Syntax

function LogN(const AValue: TComplex, const X: Double): TComplex;

Description

LogN returns the log base Base of X.
=====================================================

 

Kurtosis Routine Calculates  kurtosis.

Syntax

function Kurtosis(const Data: array of Double (1,2,3...)): Extended;

Description

Kurtosis calculates the core factors of statistical analysis: kurtosis. Data specifies the data to be analyzed. Kurtosis reflects flatness of distribution

=====================================================

 

Max Routine Returns the largest signed value in an array.

Syntax

function Max(const Data: array of Double (1,2,3...)): Double;

Description

Max returns the largest signed value in the Data array.

=====================================================

 

Mean Routine Returns the average of all values in an array.

Syntax

function Mean(const Data: array of Double): Extended;

Description

Mean calculates the arithmetic average of all the values in the Data array parameter.
=====================================================

 

Min Routine Returns smallest signed value in an array.

Syntax

function Min(const Data: array of Double (1,2,3,...)): Double;

Description

Min returns the smallest signed value in the Data array.
=====================================================

 

Moment3 Routine Calculates the Moment 3.

Syntax

function Moment3(const Data: array of Double (1,2,3,...)): Double;

Description

Moment3 calculates the core factors of statistical analysis: the Moment 3. Data specifies the data to be analyzed.

=====================================================

 

Moment4 Routine Calculates the Moment 4.

Syntax

function Moment4(const Data: array of Double (1,2,3,...)): Double;

Description

Moment4 calculates the core factors of statistical analysis: the Moment 4. Data specifies the data to be analyzed.

=====================================================

 

NetPresentValue Routine Calculates the current value from an array of estimated cash flow values.

Syntax

function NetPresentValue(const Rate: Extended, const CashFlows: array of Double (1,2,3...,), PaymentTime: TPaymentTime): Extended

Description

NetPresentValue calculates the current value of an array of estimated cash flow values, discounted at the given interest rate of Rate. CashFlows is the array of estimated cash flow values. PaymentTime indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning). NetPresentValue helps determine how much an investment is currently worth, based on expected earnings, although its accuracy depends on the accuracy of the cash flows in the array.

=====================================================

 

Norm Routine Returns the Euclidean 'L-2' norm.

Syntax

function Norm(const Data: array of Double (1,2,3...)): Extended;

Description

Norm returns the Euclidean 'L-2' norm for the values in the Data array. The 'L-2' norm is the square root of the sum of squares.

=====================================================

 

NumberOfPeriods Routine Returns the number of payment periods for an investment.

Syntax

function NumberOfPeriods(const Rate: Extended, Payment: Extended, const PresentValue: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

NumberOfPeriods computes the number of payment periods required for an investment of PresentValue to reach a value of FutureValue, while making regular payments of Payment and accruing interest at the rate of Rate per compounding period. PaymentTime indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning). 
=====================================================

 

Payment Routine Calculates a fully amortized payment.

Syntax

function Payment(Rate: Extended, NPeriods: Integer, const PresentValue: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

Payment calculates the fully amortized payment of borrowing PresentValue at Rate percent per period over NPeriods. It assumes that interest is paid at the end of each period. FutureValue is the value that the investment will reach at some point. PaymentTime indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning).
=====================================================

 

PeriodPayment Routine Returns the principal amount from a full payment.

Syntax

function PeriodPayment(const Rate: Extended, Period: Integer, NPeriods: Integer, const PresentValue: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

PeriodPayment gives the part of the payment that is principal. The InterestPayment function gives the part of the payment that is interest. The Rate parameter is the interest rate. Period is the number of periods into the loan for which the principal is desired, and NPeriods is the number of periods of the loan. FutureValue is the value the investment will reach at some point. PaymentTime indicates whether the cash flows occur at the beginning or end of the period (enter 0 if payments are at the end of each period, 1 if they are at the beginning).
=====================================================

 

PopnStdDev Routine Calculates the population standard deviation.

Syntax

function PopnStdDev(const Data: array of Double (1,2,3...)): Extended;

Description

PopnStdDev calculates the population standard deviation (the square root of the population variance) of all values in the Data array parameter. This function is used in some business and financial calculations.
=====================================================

 

PopnVariance Routine Calculates the population variance.

Syntax

function PopnVariance(const Data: array of Double (1,2,3...)): Extended;

Description

PopnVariance calculates the population variance of all values in the Data array parameter, using the n method (biased): TotalVariance / n.

=====================================================

 

Power Routine Raises Base to any power.

Syntax

function Power(const AValue: TComplex, const APower: TComplex): TComplex;

Description

Power raises Base to any power. For fractional exponents or exponents greater than MaxInt, Base must be greater than 0.
=====================================================

 

PresentValue Routine Calculates the present value of an investment.

Syntax

function PresentValue(const Rate: Extended, NPeriods: Integer, const Payment: Extended, const FutureValue: Extended, PaymentTime: TPaymentTime): Extended;

Description

PresentValue calculates the present value of an investment where Payment is received for NPeriods and is discounted at the rate of Rate per period. FutureValue is the value the investment may reach at some point. PaymentTime indicates whether the cash flows occur at the beginning or end of the period(enter 0 if payments are at the end of each period, 1 if they are at the beginning).
=====================================================

 

RadToDeg Routine Converts radians to degrees.

Syntax

function RadToDeg(const Radians: Extended): Extended;

Description

Use RadToDeg to convert angles measured in radians to degrees, where degrees = radians(180/pi).
=====================================================

 

Sec, Secant Routines Calculates the secant of an angle.

Syntax

function Sec(const AValue: TComplex): TComplex;

Description

Call Sec to obtain the secant of X, where X is an angle in radians. The secant is calculated using the formula 1 / Cos(X).

=====================================================

 

SecH Routine Calculates the hyperbolic secant of an angle.

Syntax

function SecH(const AValue: TComplex): TComplex;

Description

Call SecH to obtain the hyperbolic secant of X, where X is an angle in Radians.
=====================================================

 

Sign Routine Indicates whether a numeric value is positive, negative, or zero.

Syntax

function Sign(const AValue: TComplex): TComplex;

Description

Use Sign to test the sign of a numeric value. Sign returns 0 if AValue is zero. 1 if AValue is greater than zero. -1 if AValue is less than zero.
=====================================================

 

Sin Routine Returns the sine of the angle in radians.

Syntax

function Sin(const AValue: TComplex): TComplex;

Description

In Delphi code, the Sin function returns the sine of the argument. X is a real-type expression. Sin returns the sine of the angle X in radians.
=====================================================

 

SinH Routine Returns the hyperbolic sine of an angle.

Syntax

function SinH(const AValue: TComplex): TComplex;

Description

Sinh calculates the hyperbolic sine of X.
=====================================================

 

SLNDepreciation Routine Returns the straight-line depreciation allowance of an asset.

Syntax

function SLNDepreciation(const Cost: Extended, const Salvage: Extended, Life: Integer): Extended;

Description

SLNDepreciation calculates the straight-line depreciation allowance for an asset over one period of its life. The function divides the Cost minus the Salvage by the number of years of useful Life of the asset. Cost is the amount initially paid for the asset. Salvage is the value of the asset at the end of its useful life.

=====================================================

 

Skew Routine Calculates skew.

Syntax

function Skew(const Data: array of Double (1,2,3...)): Extended;

Description

Skew calculates the core factors of statistical analysis: skew. Data specifies the data to be analyzed. Skew reflects symmetry of distribution.
=====================================================

 

StdDev Routine Returns the sample standard deviation for elements in an array.

Syntax

function StdDev(const Data: array of Double (1,2,3...)): Extended;

Description

StdDev calculates the sample standard deviation (the square root of the sample variance) of all values in the Data array parameter.

=====================================================

 

Sum Routine Returns the sum of the elements in an array.

Syntax

function Sum(const Data: array of Double (1,2,3...)): Extended;

Description

Sum returns the sum of all the values in the Data array parameter.

=====================================================

 

SumOfSquares Routine Returns the sum of the squared values from a data array.

Syntax

function SumOfSquares(const Data: array of Double (1,2,3...)): Extended;

Description

SumOfSquares returns the sum of the squares of the Data values: Data[0]^2 + Data[1]^2 + Data[2]^2...

=====================================================

 

Sqr Routine Returns the square of a number.

Syntax

function Sqr(const AValue: TComplex): TComplex;

Description

In Delphi code, the Sqr function returns the square of the argument. X is a floating-point expression. The result, of the same type as X, is the square of X, or X*X.

=====================================================

 

Sqrt Routine Returns the square root of X.

Syntax

function Sqrt(const AValue: TComplex): TComplex;

Description

X is a Delphi floating-point expression. The result is the square root of X.
=====================================================

 

SYDDepreciation Routine Calculates depreciation for an asset.

Syntax

function SYDDepreciation(const Cost: Extended, const Salvage: Extended, Life: Integer, Period: Integer): Extended;

Description

SYDDepreciation (for "sum-of-years-digits depreciation") calculates depreciation amounts for an asset using an accelerated depreciation method. This allows for higher depreciation in the earlier years of an asset's life. Cost is the initial cost of the asset. Salvage is the value of the asset at the end of its life expectancy. Life is the length of the asset's life expectancy. Period is the period for which to calculate the depreciation

=====================================================

 

Tan Routine Returns the tangent of X.

Syntax

function Tan(const AValue: TComplex): TComplex;

Description

Tan returns the tangent of X. Tan(X) = Sin(X) / Cos(X).
=====================================================

 

TanH Routine Returns the hyperbolic tangent of X.

Syntax

function TanH(const AValue: TComplex): TComplex;

Description

Tanh calculates the hyperbolic tangent of X.
=====================================================

 

TotalVariance Routine Returns the statistical variance from an array of values.

Syntax

function TotalVariance(const Data: array of Double (1,2,3...)): Extended;

Description

TotalVariance returns the sum of the squares of the difference between each Data value and the mean of the data values. Total Variance: SUM(i=1,N)[(X(i) - Mean)**2]
=====================================================

 

Variance Routine Calculates statistical sample variance from an array of data.

Syntax

function Variance(const Data: array of Double (1,2,3...)): Extended;

Description

Variance calculates the sample variance of all values in the Data array parameter, using the n-1 method (unbiased).

 

 

Statistical Routines for Probability and Distributions Category

=====================================================

 

Beta Function

Returns Beta(X,Y) using a Series Expansion for 1/Gamma (X) as defined in Abramowitz & Stegun.

 

Declaration

Function Beta(const X, Y: Extended): Extended;

 

Description

Defined for all values of X and Y except negative integers and 0.

 

Accuracy: Gives about 15 digits.

 

Parameters

X  First Value to process.

Y  Second Value to process.

=====================================================

 

Gamma Function

Returns Gamma(X) using a Series Expansion for 1/Gamma (X) as defined in Abramowitz & Stegun.

 

Declaration

Function Gamma(const X: Extended): Extended;

 

Description

Defined for all values of X except negative integers and 0.

 

Accuracy: Gives about 15 digits.

 

Parameters

X  Value to process.

=====================================================

 

Hermite Function

Returns a Hermite Polynomial of order N evaluated at X.

 

Declaration

Function Hermite(const X: Extended; const N: LongWord): Extended;

 

Parameters

X  Value to process.

N  Order of Hermite

=====================================================

 

IncompleteBeta Function

Returns the Incomplete Beta Ix(P, Q), where 0 <= X <= 1 and P and Q are positive.

 

Declaration

Function IncompleteBeta(X: Extended; P, Q: Extended): Extended;

 

Description

The Incomplete Beta function is the probability that a random variable from a Beta distribution having parameters P and Q will be less than or equal to X. Accuracy: Gives about 17 digits. Adapted From Collected Algorithms from CACM, Algorithm 179 - Incomplete Beta Function Ratios, Oliver G Ludwig.

=====================================================

 

InverseGamma Function

Returns 1/Gamma(X) using a Series Expansion as defined in Abramowitz & Stegun.

 

Declaration

Function InverseGamma(const X: Extended): Extended;

 

Description

Defined for all values of X.

 

Accuracy: Gives about 15 digits.

 

Parameters

X  Value to process.

=====================================================

 

LnBeta Function

Returns the Natural Logarithm of Beta(X,Y) using a LnGamma (X) as defined above.

 

Declaration

Function LnBeta(const X, Y: Extended): Extended;

 

Description

X and Y must be positive.

 

Accuracy: Gives about 15 digits.

 

Parameters

X  First Value to process.

Y  Second Value to process.

=====================================================

 

LnGamma Function

Logarithm to base e of the gamma function.

 

Declaration

Function LnGamma(const X: Extended): Extended;

 

Description

Defined for all positive values of X.

 

Accurate to about 14 digits.

 

Programmer: Alan Miller - developed for Fortan 77, converted with permission.

 

Parameters

X  Value to process.

=====================================================

 

BinomialBetween Function

Returns the Result for Pr (A < X < B) for a Binomial Distribution of N Trials where the probability of a success = P.

 

Declaration

Function BinomialBetween(const P: Extended; const N, A, B: LongWord): Extended;

 

Parameters

P  Probability of Success, 0 <= P <= 1

N  Number of Trials, must be positive.

A  Lower Value at which to evaluate.

B  Upper Value at which to evaluate.

=====================================================

 

BinomialCoeff Function

Returns the Binomial Coefficient of N by R as an Extended Float, thus allowing for large values.

 

Declaration

Function BinomialCoeff(const N, R: LongWord): Extended;

 

Description

Binomial Coefficient of N by R is also known as the Combination of N by R, written as nCr,

which is the number of ways you can arrange R objects from N objects, when order is unimportant.

 

Binomial Coefficients as R goes from 0 to N are the coefficients of the terms when expanding (a + b)^N.

 

Parameters

N  Total Number of Items.

R  Number of Chosen Items

 

=====================================================

 

BinomialEq Function

Returns the Result for Pr (X = A) for a Binomial Distribution of N Trials where the probability of a success = P.

 

Declaration

Function BinomialEq(const P: Extended; const N, A: LongWord): Extended;

 

Parameters

P  Probability of Success, 0 <= P <= 1

N  Number of Trials, must be positive.

A  Value at which to evaluate.

=====================================================

 

BinomialGreater Function

Returns the Result for Pr (X > A) for a Binomial Distribution of N Trials where the probability of a success = P.

 

Declaration

Function BinomialGreater(const P: Extended; const N, A: LongWord): Extended;

 

Parameters

P  Probability of Success, 0 <= P <= 1

N  Number of Trials, must be positive.

A  Value at which to evaluate.

=====================================================

 

BinomialLess Function

Returns the Result for Pr (X < A) for a Binomial Distribution of N Trials where the probability of a success = P.

 

Declaration

Function BinomialLess(const P: Extended; const N, A: LongWord): Extended;

 

Parameters

P  Probability of Success, 0 <= P <= 1

N  Number of Trials, must be positive.

A  Value at which to evaluate.

=====================================================

 

ChiSquareBetween Function

Calculates the Pr (Chi2A < X < Chi2B) with given Degrees of Freedom (DF), using a Series Expansion as defined in Abramowitz & Stegun.

 

Declaration

Function ChiSquareBetween(const Chi2A, Chi2B: Extended; const DF: LongWord): Extended;

 

Description

 

Chi2 must be NonNegative and DF > 0.

 

Uses NormalGreater and NormalZ thus has a high degree of accuracy.

 

Parameters

Chi2A  Lower Value at which to Evaluate, must be Non-Negative.

Chi2B  Upper Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

ChiSquareGreater Function

Calculates the Pr (X > Chi2) with given Degrees of Freedom (DF), using a Series Expansion as defined in Abramowitz & Stegun.

 

Declaration

Function ChiSquareGreater(const Chi2: Extended; const DF: LongWord): Extended;

 

Description

Chi2 must be NonNegative and DF > 0.

 

This uses NormalGreater and NormalZ and has a high degree of accuracy.

 

Parameters

Chi2  Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

ChiSquareLess Function

Calculates the Pr (X < Chi2) with given Degrees of Freedom (DF), using a Series Expansion as defined in Abramowitz & Stegun.

 

Declaration

Function ChiSquareLess(const Chi2: Extended; const DF: LongWord): Extended;

 

Description

This uses NormalGreater and NormalZ and has a high degree of accuracy.

 

Parameters

Chi2  Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

ExponentialBetween Function

Returns the Result for Pr (A < X < B) for an Exponential Distribution with given Mean.

 

Declaration

Function ExponentialBetween(const Mu, A, B: Extended): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Lower Value at which to evaluate, must be Non-Negative.

B  Upper Value at which to evaluate, must be Non-Negative.

=====================================================

 

ExponentialGreater Function

Returns the Result for Pr (X > A) for an Exponential Distribution with given Mean.

 

Declaration

Function ExponentialGreater(const Mu, A: Extended): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Value at which to evaluate, must be Non-Negative

=====================================================

 

ExponentialLess Function

Returns the Result for Pr (X < A) for an Exponential Distribution with given Mean.

 

Declaration

Function ExponentialLess(const Mu, A: Extended): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Value at which to evaluate, must be Non-Negative.

=====================================================

 

FDistBetween Function

Calculates the Pr (FA < X < FB) with given Degrees of Freedom (DF1, DF2), for a F Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function FDistBetween(const FA, FB: Extended; const DF1, DF2: LongWord): Extended;

 

Parameters

FA  Lower Value at which to Evaluate, must be Non-Negative.

FB  Upper Value at which to Evaluate, must be Non-Negative.

DF1  First Degrees of Freedom, must be Positive.

DF2  Second Degrees of Freedom, must be Positive.

=====================================================

 

FDistGreater Function

Calculates the Pr (X > F) with given Degrees of Freedom (DF1, DF2) for a F Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function FDistGreater(const F: Extended; const DF1, DF2: LongWord): Extended;

 

Parameters

F  Value at which to Evaluate, must be Non-Negative.

DF1  First Degrees of Freedom, must be Positive.

DF2  Second Degrees of Freedom, must be Positive.

=====================================================

 

FDistLess Function

Calculates the Pr (X < F) with given Degrees of Freedom (DF1, DF2) for a F Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function FDistLess(const F: Extended; const DF1, DF2: LongWord): Extended;

 

Parameters

F  Value at which to Evaluate, must be Non-Negative.

DF1  First Degrees of Freedom, must be Positive.

DF2  Second Degrees of Freedom, must be Positive.

=====================================================

 

IncompleteGamma Function

Returns Incomplete Gamma(X) (small gamma).

 

Declaration

Function IncompleteGamma(const P, X: Extended): Extended;

 

Description

ALGORITHM AS239 APPL. STATIST. (1988) VOL. 37, NO. 3 Computation of the Incomplete Gamma Integral This has a high degree of accuracy.

 

Parameters

P  Must be Positive.

X  Must be Non-Negative.

=====================================================

IncompleteGamma2 Function

Returns Incomplete Gamma(X) (big gamma) derived from ChiSquareGreater as defined in Abramowitz & Stegun.

 

Declaration

Function IncompleteGamma2(const A, X: Extended): Extended;

 

Description

This uses NormalGreater and NormalZ and has a high degree of accuracy.

 

Parameters

A  Must be Positive.

X  Must be Non-Negative.

=====================================================

 

InvChiSquareGreater Function

Returns the Original Chi2 for Pr (X > Chi2) = PVal for a Chi-Square Distribution with given Degrees of Freedom.

 

Declaration

Function InvChiSquareGreater(const PVal: Extended; const DF: LongWord): Extended;

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

InvChiSquareLess Function

Returns the Original Chi2 for Pr (X < Chi2) = PVal for a Chi-Square Distribution with given Degrees of Freedom.

 

Declaration

Function InvChiSquareLess(const PVal: Extended; const DF: LongWord): Extended;

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

InvFDistGreater Function

Returns the Original F for Pr (X > F) = PVal for a F Distribution with given Degrees of Freedom.

 

Declaration

Function InvFDistGreater(const PVal: Extended; const DF1, DF2: LongWord): Extended;

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF1  First Degrees of Freedom, must be Positive.

DF2  Second Degrees of Freedom, must be Positive.

=====================================================

 

InvFDistLess Function

Returns the Original F for Pr (X < F) = PVal for a F Distribution with given Degrees of Freedom.

 

Declaration

Function InvFDistLess(const PVal: Extended; const DF1, DF2: LongWord): Extended;

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF1  First Degrees of Freedom, must be Positive.

DF2  Second Degrees of Freedom, must be Positive.

=====================================================

 

InvLogNormalGreater Function

Returns the Original AVal for Pr (X > AVal) = PVal for a LogNormal Distribution with given Mean and Standard Deviation.

 

Declaration

Function InvLogNormalGreater(const Mean, StdDev, PVal: Extended): Extended;

 

Description

Uses an approximation from Abramowitx & Stegun, which is then refined for increased accuracy.

 

Standard Deviation must be > 0

 

PVal (Probability) must be 0 < PVal < 1

 

Accuracy: to about 15 sifnicant figures.

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

PVal  Probability to use.

=====================================================

 

InvLogNormalLess Function

Returns the Original AVal for Pr (X < AVal) = PVal if Less is True, or Pr (X > AVal) = PVal if Less is False, for a LogNormal Distribution with given Mean and Standard Deviation.

 

Declaration

Function InvLogNormalLess(const Mean, StdDev, PVal: Extended): Extended;

 

Description

Uses an approximation from Abramowitx & Stegun, which is then refined for increased accuracy.

 

Standard Deviation must be > 0

 

PVal (Probability) must be 0 < PVal < 1

 

Accuracy: to about 15 sifnicant figures.

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

PVal  Probability to use.

=====================================================

 

InvNormalDistGreater Function

Returns the Original AVal for Pr (X > AVal) = PVal for a Normal Distribution with given Mean and Standard Deviation.

 

Declaration

Function InvNormalDistGreater(const Mean, StdDev, PVal: Extended): Extended;

 

Description

Uses an approximation from Abramowitx & Stegun, which is then refined for increased accuracy.

 

Standard Deviation must be > 0

 

PVal (Probability) must be 0 < PVal < 1

 

Accuracy: to about 15 sifnicant figures

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

PVal  Probability to use.

=====================================================

 

InvNormalGreater Function

Returns Inverse Q(X) for the Standard Normal Distribution.

 

Declaration

Function InvNormalGreater(const P: Extended): Extended;

 

Description

The P passed in is the probability and thus must have 0 < P < 1.

 

This uses an Algorithm that gives about 16 digit accuracy!

 

Based on Algorithm AS241 (in Fortran) from Applied Statistics (1988) Vol. 37, no. 3, 477-484.

 

Parameters

P  Probability to process.

=====================================================

 

InvNormalLess Function

Returns Inverse P(X) for the Standard Normal Distribution.

 

Declaration

Function InvNormalLess(const P: Extended): Extended;

 

Description

The P passed in is the probability and thus must have 0 < P < 1.

 

This uses an Algorithm that gives about 16 digit accuracy!

 

Based on Algorithm AS241 (in Fortran) from Applied Statistics (1988) Vol. 37, no. 3, 477-484.

 

Parameters

P  Probability to process.

=====================================================

 

InvStudentTGreater Function

Returns the Original T for Pr (X > T) = PVal for a Student T Distribution with given Degrees of Freedom.

 

Declaration

Function InvStudentTGreater(const PVal: Extended; const DF: LongWord): Extended;

 

Description

Accuracy: to about 15 significant digits. Much less accuracy when Degrees of Freedom > 1500

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

InvStudentTLess Function

Returns the Original T for Pr (X < T) = PVal for a Student T Distribution with given Degrees of Freedom.

 

Declaration

Function InvStudentTLess(const PVal: Extended; const DF: LongWord): Extended;

 

Description

Accuracy: to about 15 significant digits. Much less accuracy when Degrees of Freedom > 1500

 

Parameters

PVal  Probability at which to Evaluate, must be 0 < PVal < 1.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

LogNormalBetween Function

Returns the Probability of (AVal < X < BVal) for a LogNormal Distribution with given Mean and Standard Deviation.

 

Declaration

Function LogNormalBetween(const Mean, StdDev, AVal, BVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Lower Value at which to evaluate.

BVal  Upper Value at which to evaluate.

=====================================================

 

LogNormalGreater Function

Returns the Probability of (X > AVal) for a LogNormal Distribution with given Mean and Standard Deviation.

 

Declaration

Function LogNormalGreater(const Mean, StdDev, AVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Value at which to evaluate.

=====================================================

 

LogNormalLess Function

Returns the Probability of (X < AVal) for a LogNormal Distribution with given Mean and Standard Deviation.

 

Declaration

Function LogNormalLess(const Mean, StdDev, AVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Value at which to evaluate.

=====================================================

 

LogNormalPDF Function

Returns the value of the LogNormal Probability Distribution Function at given value X, for given Mean and Standard Deviation.

 

Declaration

Function LogNormalPDF(const X, Mean, StdDev: Extended): Extended;

 

Description

Full Accuracy of FPU. This is the function that defines the LogNormal Distribution Curve.

 

Parameters

X  Value to process.

Mean  Mean of the LogNormal Distribution

StdDev  Standard Deviation of the LogNormal Distribution

=====================================================

 

NormalDistBetween Function

Returns the Probability of (AVal < X < BVal) for a Normal Distribution with given Mean and Standard Deviation.

 

Declaration

Function NormalDistBetween(const Mean, StdDev, AVal, BVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Lower Value at which to evaluate.

BVal  Upper Value at which to evaluate.

=====================================================

 

NormalDistGreater Function

Returns the Probability of (X > AVal) for a Normal Distribution with given Mean and Standard Deviation.

 

Declaration

Function NormalDistGreater(const Mean, StdDev, AVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Value at which to evaluate.

=====================================================

 

NormalDistLess Function

Returns the Probability of (X < AVal) for a Normal Distribution with given Mean and Standard Deviation.

 

Declaration

Function NormalDistLess(const Mean, StdDev, AVal: Extended): Extended;

 

Description

Standard Deviation must be > 0 or function will result in an EMathError.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

Mean  Arithmetic Mean of the Distribution.

StdDev  Standard Deviation of the Distribution. If you have Variance then use its Positive Square Root.

AVal  Value at which to evaluate.

=====================================================

 

NormalGreater Function

Returns Q(X) for the Standard Normal Distribution as defined by Abramowitz & Stegun.

 

Declaration

Function NormalGreater(const X: Extended): Extended;

 

Description

This is the Probability that a value is greater than X, ie Area under the curve defined by NormalZ to the Right of X

 

Only handles values X >= 0 otherwise exception raised.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

X  Value to process.

=====================================================

 

NormalLess Function

Returns P(X) for the Standard Normal Distribution as defined by Abramowitz & Stegun.

 

Declaration

Function NormalLess(const X: Extended): Extended;

 

Description

This is the Probability that a value is less than X, ie Area under the curve defined by NormalZ to the left of X.

 

Only handles values X >= 0 otherwise exception raised.

 

Accuracy: Uses a Power series trying to get 18 digit accuracy or Maximum Iterations (100).

 

Parameters

X  Value to process.

=====================================================

 

NormalPDF Function

Returns the value of the Normal Probability Distribution Function at given value X, for given Mean and Standard Deviation.

 

Declaration

Function NormalPDF(const X, Mean, StdDev: Extended): Extended;

 

Description

Full Accuracy of FPU. This is the function that defines the Normal Distribution Curve.

 

Parameters

X  Value to process.

Mean  Mean of the Normal Distribution.

StdDev  Standard Deviation of the Normal Distribution.

=====================================================

 

NormalZ Function

Returns Z(X) for the Standard Normal Distribution as defined by Abramowitz & Stegun.

 

Declaration

Function NormalZ(const X: Extended): Extended;

 

Description

This is the function that defines the Standard Normal Distribution Curve. Full Accuracy of FPU.

 

Parameters

X  Value to process.

=====================================================

 

Permutation Function

Returns the Permutation of N by R, often written nPr, as an Extended Float, thus allowing for large values.

 

Declaration

Function Permutation(const N, R: LongWord): Extended;

 

Description

Permutation of N by R is the number of ways you can arrange R objects from N objects, when order is important.

 

Parameters

N  Total Number of Items.

R  Number of Chosen Items.

=====================================================

 

PoissonBetween Function

Returns the Result for Pr (A < X < B) for a Poisson Distribution with given Mean.

 

Declaration

Function PoissonBetween(const Mu: Extended; const A, B: LongWord): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Lower Value at which to evaluate.

B  Upper Value at which to evaluate.

=====================================================

 

PoissonEq Function

Returns the Result for Pr (X = A) for a Poisson Distribution with given Mean.

 

Declaration

Function PoissonEq(const Mu: Extended; const A: LongWord): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Value at which to evaluate.

=====================================================

 

PoissonGreater Function

Returns the Result for Pr (X > A) for a Poisson Distribution with given Mean.

 

Declaration

Function PoissonGreater(const Mu: Extended; const A: LongWord): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Value at which to evaluate.

=====================================================

 

PoissonLess Function

Returns the Result for Pr (X < A) for a Poisson Distribution with given Mean.

 

Declaration

Function PoissonLess(const Mu: Extended; const A: LongWord): Extended;

 

Parameters

Mu  Mean of the Distribution, must be Positive.

A  Value at which to evaluate.

=====================================================

 

StudentTBetween Function

Calculates the Pr (TA < X < TB) with given Degrees of Freedom (DF) for a Student T Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function StudentTBetween(const TA, TB: Extended; const DF: LongWord): Extended;

 

Parameters

TA  Lower Value at which to Evaluate, must be Non-Negative.

TB  Upper Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

StudentTGreater Function

Calculates the Pr (X > T) with given Degrees of Freedom (DF) for a Student T Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function StudentTGreater(const T: Extended; const DF: LongWord): Extended;

 

Parameters

T  Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

StudentTLess Function

Calculates the Pr (X < T) with given Degrees of Freedom (DF) for a Student T Distribution, using a Incomplete Beta Function as defined in Abramowitz & Stegun.

 

Declaration

Function StudentTLess(const T: Extended; const DF: LongWord): Extended;

 

Parameters

T  Value at which to Evaluate, must be Non-Negative.

DF  Degrees of Freedom, must be Positive.

=====================================================

 

ZAlpha Function

Returns the Standardised Normal Value (Z) that results in a Tail Area of given AVal.

 

Declaration

Function ZAlpha(const AVal: Extended): Extended;

 

Parameters

AVal  Value at which to evaluate

 

 

Date and Time Routines Category

=====================================================

 

CompareDate Routine Indicates the relationship between the date portions of two TDateTime values.

Syntax

function CompareDate(const A: TDateTime, const B: TDateTime): TValueRelationship;

Description

Call CompareDate to compare the two TDateTime values specified by A and B. CompareDate returns LessThanValue if A occurs on a day prior to the day specified by B. EqualsValue if A occurs on the same day as B, ignoring the time of day. GreaterThanValue if A occurs on a day that follows the day specified by B.

=====================================================

 

CompareDateTime Routine Indicates the relationship between two TDateTime values.

Syntax

function CompareDateTime(const A: TDateTime, const B: TDateTime): TValueRelationship;

Description

Call CompareDateTime to compare the two TDateTime values specified by A and B. CompareDateTime returns LessThanValue if A is earlier than B. EqualsValue if A is the same as B. GreaterThanValue if A is later than B.

Note: Note:CompareDateTime differs from a direct comparison of the corresponding double precision values in that two TDateTime values are considered the same if they have the same value down to the millisecond. It is possible to create two TDateTime values that differ numerically when viewed as doubles, but which represent the same year, month, day, hour, minute, second, and millisecond.

=====================================================

 

CompareTime Routine Indicates the relationship between the time portions of two TDateTime values.

Syntax

function CompareTime(const A: TDateTime, const B: TDateTime): TValueRelationship;

Description

Call CompareTime to compare the two TDateTime values specified by A and B. CompareTime returns LessThanValue if A occurs earlier in the day than B (even if A occurs on a later day than B). EqualsValue if A occurs at the same time of day as B, ignoring of the date portion of the two values. GreaterThanValue if A occurs later in the day than B (even if A occurs on an earlier day than B).

=====================================================

 

DateOf Routine Strips the time portion from a TDateTime value.

Syntax

function DateOf(const AValue: TDateTime): TDateTime;

Description

Call DateOf to convert a TDateTime value to a TDateTime value that includes only the date information (sets the time portion to 0, which means midnight).

=====================================================

 

DayOf Routine Returns the day of the month represented by a TDateTime value.

Syntax

function DayOf(const AValue: TDateTime): Word;

Description

Call DayOf to obtain the day of the month represented by a specified TDateTime value. DayOf returns a value between 1 and 31.

Note: Note:DayOf returns the same value as the DayOfTheMonth function.

=====================================================

 

DayOfTheMonth Routine Returns the day of the month represented by a TDateTime value.

Syntax

function DayOfTheMonth(const AValue: TDateTime): Word;

Description

Call DayOfTheMonth to obtain the day of the month represented by a specified TDateTime value. DayOfTheMonth returns a value between 1 and 31.

Note: Note:DayOfTheMonth returns the same value as the DayOf function.

=====================================================

 

DayOfTheWeek Routine Returns the day of the week represented by a TDateTime value.

Syntax

function DayOfTheWeek(const AValue: TDateTime): Word;

Description

Call DayOfTheWeek to obtain the day of the week represented by a specified TDateTime value. DayOfTheWeek returns a value between 1 and 7, where 1 indicates Monday and 7 indicates Sunday.

Note: Note:DayOfTheWeek is ISO 8601 compliant (where Monday is considered the first day of the week). To obtain the day of the week where Sunday is considered the first day of the week, use the DayOfWeek function instead.

Note: Tip:To make the return value more readable, use the Day of week constants.

=====================================================

 

DayOfTheYear Routine Returns the number of days between a specified TDateTime value and December 31 of the previous year.

Syntax

function DayOfTheYear(const AValue: TDateTime): Word;

Description

Call DayOfTheYear to obtain the ordinal position of a TDateTime value’s day within its year. Thus, a TDateTime value that refers to January 1 generates a result of 1, dates on January 2 return 2, dates on February 1 return 32, and so on.

=====================================================

 

DaysBetween Routine Returns the number of whole days between two specified TDateTime values.

Syntax

function DaysBetween(const ANow: TDateTime, const AThen: TDateTime): Integer;

Description

Call DaysBetween to obtain the difference, in days, between two TDateTime values. DaysBetween counts only whole days. Thus, DaysBetween reports the difference between Dec 31, 1999 11:59 PM and Jan 1, 2000 11:58 PM as 0 because the difference is one minute short of an entire day.

=====================================================

 

DaysInAMonth Routine Returns the number of days in a specified month of a specified year. Namespace Borland.Vcl.DateUtils

Syntax

function DaysInAMonth(const AYear: Word, const AMonth: Word): Word;

Description

Call DaysInAMonth to obtain the number of days in the specified month of the specified year. AYear is a year between 1 and 9999 (inclusive). AMonth is a month between 1 and 12 (inclusive).
=====================================================

 

DaysInMonth Routine Returns the number of days in the month of a specified TDateTime value.

Syntax

function DaysInMonth(const AValue: TDateTime): Word;

Description

Call DaysInMonth to obtain the number of days in the month of the TDateTime value specified by AValue.

=====================================================

 

DaysInAYear Routine Returns the number of days in a specified year.

Syntax

function DaysInAYear(const AYear: Word): Word;

Description

Call DaysInAYear to obtain the number of days in the year specified by AYear. AYear is a year between 1 and 9999 (inclusive).

=====================================================

 

DaysInYear Routine Returns the number of days in the year of a specified TDateTime value.

Syntax

function DaysInYear(const AValue: TDateTime): Word;

Description

Call DaysInYear to obtain the number of days in the year of the TDateTime value specified by AValue.
=====================================================

 

DaySpan Routine Returns the number of days (including fractional days) between two specified TDateTime values.

Syntax

function DaySpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

 Call DaySpan to obtain the difference, in days, between two TDateTime values. Unlike the DaysBetween function, which only counts whole days, DaySpan reports incomplete days as a fraction of an entire day.
=====================================================

 

HourOfTheDay Routine Returns the hour of the day represented by a TDateTime value.

Syntax

function HourOfTheDay(const AValue: TDateTime): Word;

Description

Call HourOfTheDay to obtain the hour of the day represented by a specified TDateTime value. HourOf returns a value between 0 and 23.

Note: Note:HourOfTheDay returns the same value as the HourOf function.

=====================================================

 

HourOfTheMonth Routine Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the month.

Syntax

function HourOfTheMonth(const AValue: TDateTime): Word;

Description

Call HourOfTheMonth to obtain the number of complete hours between AValue and 12:00 AM on the first day of the month that includes AValue.
=====================================================

 

HourOfTheWeek Routine Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the week.

Syntax

function HourOfTheWeek(const AValue: TDateTime): Word;

Description

Call HourOfTheWeek to obtain the number of complete hours between AValue and 12:00 AM on Monday of the week that includes AValue.

Note: Note:HourOfTheWeek defines the week of AValue according to the ISO 8601 standard. That is, the week starts on Monday and ends on Sunday.

=====================================================

 

HourOfTheYear Routine Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the year.

Syntax

function HourOfTheYear(const AValue: TDateTime): Word;

Description

Call HourOfTheYear to obtain the number of complete hours between AValue and 12:00 AM on Jan 1 of the year that includes AValue.
=====================================================

 

HoursBetween Routine Returns the number of whole hours between two specified TDateTime values.

Syntax

function HoursBetween(const ANow: TDateTime, const AThen: TDateTime): Int64;

Description

Call HoursBetween to obtain the difference, in hours, between two TDateTime values. HoursBetween counts only entire hours. Thus, HoursBetween reports the difference between 9:00 AM and 9:59:59 AM as 0 because the difference is one second short of an entire hour.
=====================================================

 

HourSpan Routine Returns the number of Hours (including fractional Hours) between two specified TDateTime values.

Syntax

function HourSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call HourSpan to obtain the difference, in hours, between two TDateTime values. Unlike the HoursBetween function, which only counts entire hours, HourSpan reports incomplete hours as a fraction of an entire hour.

=====================================================

 

IncDay Routine Returns a date shifted by a specified number of days.

Syntax

function IncDay(const AValue: TDateTime, const ANumberOfDays: Integer): TDateTime;

Description

IncDay returns the value of the AValue parameter, incremented by ANumberOfDays days. ANumberOfDays can be negative, to return a date N days previous. The time of day specified by the AValue parameter is copied to the result.
=====================================================

 

IncHour Routine Returns a date/time value shifted by a specified number of hours.

Syntax

function IncHour(const AValue: TDateTime, const ANumberOfHours: Int64): TDateTime;

Description

IncHour returns the value of the AValue parameter, incremented by ANumberOfHours hours. ANumberOfHours can be negative, to return a date and time N hours prior to AValue.
=====================================================

 

IncMilliSecond Routine Returns a date/time value shifted by a specified number of milliseconds.

Syntax

function IncMilliSecond(const AValue: TDateTime, const ANumberOfMilliSeconds: Int64): TDateTime;

Description

IncMilliSecond returns the value of the AValue parameter, incremented by ANumberOfMilliSeconds milliseconds. ANumberOfMilliSeconds can be negative, to return a date and time N milliseconds prior to AValue.
=====================================================

 

IncMinute Routine Returns a date/time value shifted by a specified number of minutes.

Syntax

function IncMinute(const AValue: TDateTime, const ANumberOfMinutes: Int64): TDateTime;

Description

IncMinute returns the value of the AValue parameter, incremented by ANumberOfMinutes minutes. ANumberOfMinutes can be negative, to return a date and time N minutes prior to AValue.

=====================================================

 

IncSecond Routine Returns a date/time value shifted by a specified number of seconds.

Syntax

function IncSecond(const AValue: TDateTime, const ANumberOfSeconds: Int64): TDateTime;

Description

IncSecond returns the value of the AValue parameter, incremented by ANumberOfSeconds seconds. ANumberOfSeconds can be negative, to return a date and time N seconds prior to AValue

=====================================================

 

IncWeek Routine Returns a date shifted by a specified number of weeks.

Syntax

function IncWeek(const AValue: TDateTime, const ANumberOfWeeks: Integer): TDateTime;

Description

IncWeek returns the value of the AValue parameter, incremented by ANumberOfWeeks weeks. ANumberOfWeeks can be negative, to return a date N weeks previous. The time of day specified by the AValue parameter is copied to the result.

=====================================================

 

IncYear Routine Returns a date shifted by a specified number of years.

Syntax

function IncYear(const AValue: TDateTime, const ANumberOfYears: Integer): TDateTime;

Description

IncYear returns the value of the AValue parameter, incremented by ANumberOfYears years. ANumberOfYears can be negative, to return a date N years previous. The time of day specified by the AValue parameter is copied to the result.

=====================================================

 

IsInLeapYear Routine Indicates whether a specified TDateTime value occurs in a leap year.

Syntax

function IsInLeapYear(const AValue: TDateTime): Boolean;

Description

Call IsInLeapYear to determine whether the year of the date specified by AValue occurs in a leap year.

=====================================================

 

IsPM Routine Indicates whether the time portion of a specified TDateTime value occurs after noon.

Syntax

function IsPM(const AValue: TDateTime): Boolean;

Description

IsPM returns true if the time portion of AValue occurs on or after 12:00 noon and before 12:00 midnight.
=====================================================

 

IsSameDay Routine Indicates whether a specified TDateTime value occurs on a the same day as a criterion date.

Syntax

function IsSameDay(const AValue: TDateTime, const ABasis: TDateTime): Boolean;

Description

IsSameDay returns true if AValue occurs on the same day as ABasis. The time portions of AValue and ABasis can differ. IsSameDay returns false if the date portions of AValue and ABasis differ.
=====================================================

 

MilliSecondOfTheDay Routine Returns the number of milliseconds between a specified TDateTime value and the beginning of the same day.

Syntax

function MilliSecondOfTheDay(const AValue: TDateTime): Cardinal;

Description

Call MilliSecondOfTheDay to obtain the number of milliseconds between AValue and the beginning (midnight) on the same day.
=====================================================

 

MilliSecondOfTheHour Routine Returns the number of milliseconds between a specified TDateTime value and the beginning of the same hour.

Syntax

function MilliSecondOfTheHour(const AValue: TDateTime): Cardinal;

Description

Call MilliSecondOfTheHour to obtain the number of milliseconds between AValue and the start of the same hour on the same day.
=====================================================

 

MilliSecondOfTheMinute Routine Returns the number of milliseconds between a specified TDateTime value and the beginning of the same minute.

Syntax

function MilliSecondOfTheMinute(const AValue: TDateTime): Cardinal;

Description

Call MilliSecondOfTheMinute to obtain the number of milliseconds between AValue and the start of the same minute on the same day.
=====================================================

 

MilliSecondOfTheMonth Routine Returns the number of milliseconds between a specified TDateTime value and the beginning of the month.

Syntax

function MilliSecondOfTheMonth(const AValue: TDateTime): Cardinal;

Description

Call MilliSecondOfTheMonth to obtain the number of milliseconds between the beginning (Midnight on the first day) of the month that contains AValue and AValue itself.
=====================================================

 

MilliSecondOfTheSecond Routine Returns the millisecond of the second represented by a TDateTime value.

Syntax

function MilliSecondOfTheSecond(const AValue: TDateTime): Word;

Description

Call MilliSecondOfTheSecond to obtain the millisecond of the second represented by a specified TDateTime value. MilliSecondOfTheSecond returns a value between 0 and 999.

Note: Note:MilliSecondOfTheSecond returns the same value as the MilliSecondOf function.

=====================================================

 

MilliSecondOfTheWeek Routine Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the week.

Syntax

function MilliSecondOfTheWeek(const AValue: TDateTime): Cardinal;

Description

Call MilliSecondOfTheWeek to obtain the number of milliseconds between AValue and 12:00:00:00 AM on Monday of the week that includes AValue.

Note: Note:MilliSecondOfTheWeek defines the week of AValue according to the ISO 8601 standard. That is, the week starts on Monday and ends on Sunday.

=====================================================

 

MilliSecondOfTheYear Routine Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the year.

Syntax

function MilliSecondOfTheYear(const AValue: TDateTime): Int64;

Description

Call MilliSecondOfTheYear to obtain the number of milliseconds between AValue and 12:00:00:00 AM on Jan 1 of the year that includes AValue.
=====================================================

 

MilliSecondsBetween Routine Returns the number of milliseconds between two specified TDateTime values.

Syntax

function MilliSecondsBetween(const ANow: TDateTime, const AThen: TDateTime): Int64;

Description

Call MilliSecondsBetween to obtain the difference, in milliseconds, between two TDateTime values.

=====================================================

 

MilliSecondSpan Routine Returns the number of milliseconds between two specified TDateTime values.

Syntax

function MilliSecondSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call MilliSecondSpan to obtain the difference, in milliseconds, between two TDateTime values. MilliSecondSpan returns the same value as MilliSecondsBetween, but as a floating point type instead of an integer.
=====================================================

 

MinuteOfTheDay Routine Returns the number of minutes between a specified TDateTime value and 12:00 AM of the same day.

Syntax

function MinuteOfTheDay(const AValue: TDateTime): Word;

Description

Call MinuteOfTheDay to obtain the number of minutes between AValue and 12:00 AM on the same day.
=====================================================

 

MinuteOfTheHour Routine Returns the number of minutes between a specified TDateTime value and the beginning of the same hour.

Syntax

function MinuteOfTheHour(const AValue: TDateTime): Word;

Description

Call MinuteOfTheHour to obtain the number of minutes between AValue and the start of the same hour on the same day.

Note: Note:MinuteOfTheHour returns the same value as the MinuteOf function.

=====================================================

 

MinuteOfTheMonth Routine Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the month.

Syntax

function MinuteOfTheMonth(const AValue: TDateTime): Word;

Description

Call MinuteOfTheMonth to obtain the number of minutes between AValue and 12:00 AM on the first day of the month that includes AValue.
=====================================================

 

MinuteOfTheWeek Routine Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the week.

Syntax

function MinuteOfTheWeek(const AValue: TDateTime): Word;

Description

Call MinuteOfTheWeek to obtain the number of minutes between AValue and 12:00 AM on Monday of the week that includes AValue.

Note: Note:MinuteOfTheWeek defines the week of AValue according to the ISO 8601 standard. That is, the week starts on Monday and ends on Sunday.

=====================================================

 

MinuteOfTheYear Routine Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the year.

Syntax

function MinuteOfTheYear(const AValue: TDateTime): Cardinal;

Description

Call MinuteOfTheYear to obtain the number of minutes between AValue and 12:00 AM on Jan 1 of the year that includes AValue.
=====================================================

 

MinutesBetween Routine Returns the number of minutes between two specified TDateTime values.

Syntax

function MinutesBetween(const ANow: TDateTime, const AThen: TDateTime): Int64;

Description

Call MinutesBetween to obtain the difference, in minutes, between two TDateTime values. MinutesBetween counts only entire minutes. Thus, MinutesBetween reports the difference between 9:00:00 AM and 9:00:59:999 AM as 0 because the difference is one millisecond short of an entire minute.
=====================================================

 

MinuteSpan Routine Returns the number of minutes, including fractions thereof, between two specified TDateTime values.

Syntax

function MinuteSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call MinuteSpan to obtain the difference, in minutes, between two TDateTime values. Unlike the MinutesBetween function, which only counts entire minutes, MinuteSpan reports incomplete minutes as a fraction of an entire minute.
=====================================================

 

MonthOfTheYear Routine Returns the month of the year represented by a TDateTime value.

Syntax

function MonthOfTheYear(const AValue: TDateTime): Word;

Description

Call MonthOfTheYear to obtain the month of the year represented by a specified TDateTime value. MonthOfTheYear returns a value between 1 and 12.

Note: Note:MonthOfTheYear returns the same value as the MonthOf function.

=====================================================

 

MonthsBetween Routine Returns the approximate number of months between two specified TDateTime values.

Syntax

function MonthsBetween(const ANow: TDateTime, const AThen: TDateTime): Integer;

Description

Call MonthsBetween to obtain the difference, in months, between two TDateTime values. Because months are not all the same length, MonthsBetween returns an approximation based on an assumption of 30.4375 days per month. Fractional months are not counted. Thus, for example, MonthsBetween reports the difference between Feb 1 and Mar 1 as 0.
=====================================================

 

MonthSpan Routine Returns the approximate number of months, including fractions, between two specified TDateTime values.

Syntax

function MonthSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call MonthSpan to obtain the difference, in months, between two TDateTime values. Because months are not all the same length, MonthsBetween returns an approximation based on an assumption of 30.4375 days per month. Unlike the MonthsBetween function, which does not report fractional “months”, MonthSpan reports incomplete months as a fraction of an entire month.

=====================================================

 

Now Routine Returns the current date and time.

Syntax

function Now: TDateTime;

Description

 Returns the current date and time, corresponding to the sum of the value returned by the global Date and Time functions.

Note: Note:Although TDateTime values can represent milliseconds, Now is accurate only to the nearest second.

=====================================================

 

NthDayOfWeek Routine Returns which occurrence of its weekday a specified TDateTime value represents.

Syntax

function NthDayOfWeek(const AValue: TDateTime): Word;

Description

NthDayOfWeek indicates which occurrence of a weekday within a month the date and time specified by AValue represents. For example, if AValue represents the 2nd Tuesday of the month, NthDayOfWeek returns 2. Note that this value may differ from the value that the WeekOfTheMonth function returns, because NthDayOfWeek counts every occurrence of the given weekday, while WeekOfTheMonth only counts a week if it includes 4 or more days in the month. Thus, for example, if AValue represents a Saturday that is the first day of a month, NthDayOfWeek returns 1, while WeekOfTheMonth returns 5 (or maybe 4), indicating the last week of the previous month.

Note: Note:To obtain the year, month, and day of the week, as well as which occurrence of that day of the week the specified TDateTime represents, use the DecodeDayOfWeekInMonth function.

=====================================================

 

SameDate Routine Indicates whether two TDateTime values represent the same year, month, and day.

Syntax

function SameDate(const A: TDateTime, const B: TDateTime): Boolean;

Description

Call SameDate to determine whether the two TDateTime values specified by A and B represent the same date, ignoring the time portion. SameDate returns true if the two specified values occur on the same day, false otherwise.
=====================================================

 

SameDateTime Routine Indicates whether two TDateTime values represent the same year, month, day, hour, minute, second, and millisecond.

Syntax

function SameDateTime(const A: TDateTime, const B: TDateTime): Boolean;

Description

Call SameDateTime to determine whether the two TDateTime values specified by A and B represent the same time, down to the millisecond. SameDateTime returns true if the two specified values represent the same time, false otherwise.

Note: Note:It is possible to create two TDateTime values that differ numerically when viewed as floating point types, but which represent the same year, month, day, hour, minute, second, and millisecond. SameDateTime allows applications to determine when two TDateTime values are the same even when their numeric values differ.

=====================================================

 

SameTime Routine Indicates whether two TDateTime values represent the same time of day, ignoring the date portion.

Syntax

function SameTime(const A: TDateTime, const B: TDateTime): Boolean;

Description

Call SameTime to determine whether the two TDateTime values specified by A and B represent the same time of day, ignoring the date portion. SameTime returns true if the two specified values occur on the same hour, minute, second, and millisecond, false otherwise.

Note: Note:It is possible to create two TDateTime values whose time portions differ numerically when viewed as floating point types, but which represent the same hour, minute, second, and millisecond. SameTime allows applications to determine when two TDateTime values represent the same time, even when the fractional parts of the values differ.

=====================================================

 

SecondOfTheDay Routine Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the same day.

Syntax

function SecondOfTheDay(const AValue: TDateTime): Cardinal;

Description

Call SecondOfTheDay to obtain the number of seconds between AValue and 12:00:00 AM on the same day.
=====================================================

 

SecondOfTheHour Routine Returns the number of seconds between a specified TDateTime value and the beginning of the same hour.

Syntax

function SecondOfTheHour(const AValue: TDateTime): Word;

Description

Call SecondOfTheHour to obtain the number of seconds between AValue and the start of the same hour on the same day.

=====================================================

 

SecondOfTheMinute Routine Returns the number of seconds between a specified TDateTime value and the beginning of the same minute.

Syntax

function SecondOfTheMinute(const AValue: TDateTime): Word;

Description

Call SecondOfTheMinute to obtain the number of seconds between AValue and the start of the same minute on the same day.

Note: Note:SecondOfTheMinute returns the same value as the SecondOf function.

=====================================================

 

SecondOfTheMonth Routine Returns the number of seconds between a specified TDateTime value and 12:00:00 AM on the first day of the month.

Syntax

function SecondOfTheMonth(const AValue: TDateTime): Cardinal;

Description

Call SecondOfTheMonth to obtain the number of seconds between AValue and 12:00:00 AM on the first day of the month that includes AValue.
=====================================================

 

SecondOfTheWeek Routine Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the first day of the week.

Syntax

function SecondOfTheWeek(const AValue: TDateTime): Cardinal;

Description

Call SecondOfTheWeek to obtain the number of seconds between AValue and 12:00:00 AM on Monday of the week that includes AValue.

Note: Note:SecondOfTheWeek defines the week of AValue according to the ISO 8601 standard. That is, the week starts on Monday and ends on Sunday.

=====================================================

 

StartOfAYear Routine Returns a TDateTime that represents the first moment on the first day of a specified year.

Syntax

function StartOfAYear(const AYear: Word): TDateTime;

Description

StartOfAYear returns the first expressible moment (January 1 at 12:00:00.000 AM) of the year specified by the AYear parameter.
=====================================================

 

SecondsBetween Routine Returns the number of seconds between two specified TDateTime values.

Syntax

function SecondsBetween(const ANow: TDateTime, const AThen: TDateTime): Int64;

Description

Call SecondsBetween to obtain the difference, in seconds, between two TDateTime values. SecondsBetween counts only entire seconds. Thus, SecondsBetween reports the difference between 9:00:00 AM and 9:00:00:999 AM as 0 because the difference is one millisecond short of an entire second.
=====================================================

 

SecondSpan Routine Returns the number of seconds (including fractions thereof) between two specified TDateTime values.

Syntax

function SecondSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call SecondSpan to obtain the difference, in seconds, between two TDateTime values. Unlike the SecondsBetween function, which only counts entire seconds, SecondSpan reports incomplete seconds as a fraction of an entire second.
=====================================================

 

TimeOf Routine Strips the date portion from a TDateTime value.

Syntax

function TimeOf(const AValue: TDateTime): TDateTime;

Description

Call TimeOf to convert a TDateTime value to a TDateTime value that includes only the time information (sets the date portion to 0, which means 12/30/1899).
=====================================================

 

Today Routine Returns a TDateTime value that represents the current date.

Syntax

function Today: TDateTime;

Description

Today returns a TDateTime value with the date portion set to the current date and the time portion set to 0.
=====================================================

 

Tomorrow Routine Returns a TDateTime value that represents the following day.

Syntax

function Tomorrow: TDateTime;

Description

Tomorrow returns a TDateTime value with the date portion set to the day following the current date and the time portion set to 0.
=====================================================

 

WeekOfTheMonth Routine Returns the week of the month represented by a TDateTime value.

Syntax

function WeekOfTheMonth(const AValue: TDateTime): Word;

Description

Call WeekOfTheMonth to obtain the week of the month represented by a specified TDateTime value. WeekOfTheMonth returns a value between 1 and 6. AYear and AMonth return the year and month in which WeekOfTheMonth occurs. Note that these values may not be the same as the year and month of AValue. This is because the first week of a month is defined as the first week with four or more days in that month. Thus, if the first day of the month is a Friday, Saturday, or Sunday, the first one, two, or three days of the month are defined as belonging to the last week of the previous month. Similarly, if the last day of the month is a Monday, Tuesday, or Wednesday, then the last one, two, or three days of the month are defined as belonging to the first week of the next month.

Note: Tip:To count weeks based on the weekday of the date/time value, use the NthDayOfWeek function instead. For example, if AValue represents a Saturday that is the first day of a month, WeekOfTheMonth returns 5 (or maybe 4), indicating the last week of the previous month, while NthDayOfWeek returns 1 AValue is the first Saturday in the month.

Note: Note:WeekOfTheMonth uses the ISO 8601 standard definition of a week. That is, a week is considered to start on a Monday and end on a Sunday.

=====================================================

 

WeekOfTheYear Routine Returns the week of the year represented by a TDateTime value.

Syntax

function WeekOfTheYear(const AValue: TDateTime): Word;

Description

Call WeekOfTheYear to obtain the week of the year represented by a specified TDateTime value. WeekOfTheYear returns a value between 1 and 53. AYear returns the year in which the specified week occurs. Note that this may not be the same as the year of AValue. This is because the first week of a year is defined as the first week with four or more days in that year. This means that if the first calendar day of the year is a Friday, Saturday, or Sunday, then for the first three, two, or one days of the calendar year, WeekOfTheYear returns the last week of the previous year. Similarly, if the last calendar day of the year is a Monday, Tuesday, or Wednesday, then for the last one, two, or three days of the calendar year, WeekOfTheYear returns 1 (the first week of the next calendar year).

Note: Note:WeekOfTheYear uses the ISO 8601 standard definition of a week. That is, a week is considered to start on a Monday and end on a Sunday.

Note: Note:WeekOfTheYear returns the same value as the WeekOf function.

=====================================================

 

WeeksBetween Routine Returns the number of whole weeks between two specified TDateTime values.

Syntax

function WeeksBetween(const ANow: TDateTime, const AThen: TDateTime): Integer;

Description

Call WeeksBetween to obtain the difference, in weeks, between two TDateTime values. WeeksBetween counts only whole Weeks. Thus, WeeksBetween reports the difference between January 1 at 12:00 AM and Jan 6 at 11:58 PM as 0 because the difference is one minute short of an entire week.
=====================================================

 

WeekSpan Routine Returns the number of weeks (including fractional weeks) between two specified TDateTime values.

Syntax

function WeekSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call WeekSpan to obtain the difference, in weeks, between two TDateTime values. Unlike the WeeksBetween function, which only counts whole weeks, WeekSpan reports incomplete weeks as a fraction of an entire week.
=====================================================

 

YearOf Routine Returns the year represented by a TDateTime value.

Syntax

function YearOf(const AValue: TDateTime): Word;

Description

Call YearOf to obtain the year represented by a specified TDateTime value. YearOf returns a value between 1 and 9999.
=====================================================

 

YearsBetween Routine Returns the approximate number of years between two specified TDateTime values.

Syntax

function YearsBetween(const ANow: TDateTime, const AThen: TDateTime): Integer;

Description

Call YearsBetween to obtain the difference, in years, between two TDateTime values. Because years are not all the same length (e.g. leap years), YearsBetween returns an approximation based on an assumption of 365.25 days per year. Fractional years are not counted. Thus, for example, YearsBetween reports the difference between Jan 1 and Dec 31 as 0 on non-leap years and 1 on leap years.
=====================================================

 

YearSpan Routine Returns the approximate number of years (including fractions thereof) between two specified TDateTime values.

Syntax

function YearSpan(const ANow: TDateTime, const AThen: TDateTime): Double;

Description

Call YearSpan to obtain the difference, in years, between two TDateTime values. Because years are not all the same length (e.g. leap years), YearsBetween returns an approximation based on an assumption of 365.25 days per year. Unlike the YearsBetween function, which does not report fractional years, YearSpan reports incomplete years as a fraction of a 365.25-day year.
=====================================================

 

Yesterday Routine Returns a TDateTime value that represents the preceding day.

Syntax

function Yesterday: TDateTime;

Description

Yesterday returns a TDateTime value with the date portion set to the day before the current date and the time portion set to 0.